inputid = $ (this). attr ("id"); var labelid = inputid+ "Error";//label ID//Clear the contents of the tag $ ("#" +labelid). Text (""); Let the label not show ShowError ($ ("#" +labelid)); }); When the input box loses focus, we need to verify the input data effectively, such as whether the telephone number is legal, the mailbox is legal $ (". Inputclass"). blur (function (){//First judge the current is that input box is called var inputID = $ (this). attr ("id"); //; Call
; getMessage (),'';}
/*** More code and HTML here ***/Echo'
Catch me if you can!
';
?>Error Codes Error code
As seen in the beginning of this document, the Exception class contains a getCode () method that will fetch an error code, this can useful as you can define your own error codes as well as your own error messages. as we can see at the beginning of this article, the exception class contains a verification code () method that will get the error code, which can help you define your own error
use the following code to check an email address:
Function validateEmail ($ email){$ HasAtSymbol = strpos ($ email ,"@");$ HasDot = strpos ($ email ,".");If ($ hasAtSymbol $ hasDot)Return true;ElseReturn false;}Echo validateEmail ("mitchell@devarticles.com ");?>... Or use the following code:Function validateEmail ($ email){Return ereg ("^ [a-zA-Z] + @
program. Do you prefer to check an e-mail address with the following code:
function Validateemail ($email){$hasAtSymbol = Strpos ($email, "@");$hasDot = Strpos ($email, ".");if ($hasAtSymbol $hasDot)return true;Elsereturn false;}Echo validateemail ("mitchell@devarticles.com");?>... or use the following code:
function Validateemail ($emai
the uncomfortable string check and operation methods, if you do not write code efficiently, the above two will also slow your program down. Do you prefer to use the following code to check an email address:
Function validateEmail ($ email){$ HasAtSymbol = strpos ($ email ,"@");$ HasDot = strpos ($ email ,".");If ($ hasAtSymbol $ hasDot)Return true;ElseReturn false;}Echo validateEmail ("mitc
regular expressions: Are you writing custom functions to check form data (such as one @, one point in an email address)? Do you write custom functions that loop through each character in a string, If this character matches a particular feature (for example, it is uppercase, or it is a space), then replace it? In addition to being an uncomfortable method of string checking and manipulation, the above two article will slow down your program if you don't write code efficiently. Are you more in
class directly, and then let the target class inherit the function class, because C + + can inherit multipleJava and OC are single-inheritance and do not allow multiple inheritanceIn OC, of course, we can also use the same way as Java, but there is a more powerful processing in OC, that is, the class, look at the example: we now want to give the NSString Class A way to verify the mailbox Validateemail, The NSString class in OC is not inheritable.Do n
The most convenient way is to use the jquery Validate plugin Reomte method to determine whether or not the user account is registered by Ajax request when the user registers.Jquery Validate plug-in, call remote method validation arguments, remote usage:in the Validate method, addRemote: "Calibration Method", such as:Remote: "/test/checkaccount.jsp", then the parameter passed into the checkaccount.jsp is account=$ ("#account"). Val (), this is the Jquery.validate automatic parameter, without manu
/account/validateemail",data:{Email:function () {return $ ("#email"). Val ();}} }Part of the code for the Sdg.registre.js network is omitted here }, messages : { " User.email ": { required:" Please enter your email! ", email:" Bad mailbox format! ", Remote: "The mailbox has been registered!" } //omitted here net sdg.registre.js part code }, //here omit good reach net sdg.registre.js part code });the corresponding HTM
++ can inherit more
Java and OC are single-inherited and do not allow many inheritance
In OC, we can also adopt aggregation processing in the way of Java, But there is a more powerful processing method in OC, that is, category. The following is an example: now we want to provide the NSString class with the validateEmail Method for email verification. The NSString class in OC cannot be inherited.
If you don't talk about it, check the Code directly:
N
that are used to match. A rule style is a template that matches a string that is searched.
Iv. examples
Microsoft has done a good job of grammar detection. But, as expected, in practical cases, they are very short. Here's a simple example:
' Example 1
Function Validateemail (Expression)
Dim objRegExp
Set objRegExp = New RegExp
Objregexp.pattern = "^[w.-]+@[w.-]+." [a-za-z]+$]
Validateemail = Objregexp.test
There are two verification cases: one is to directly use local verification, and the other is to use ajax to verify on the server.
I need to verify now: the user name, email address, and phone number are three input (text). The user name and phone number only need to be verified locally, as long as they match the given regular expression, the mailbox is first verified locally. If the correct format is met, Ajax will go to the server to verify whether the mailbox has been registered. If the mai
, instead
WWW
Server.
For example,
Hotmail
. Com
The email server can access,
Hotmail
. Com
Of
HTTP
Service
But not necessarily the mail server.
Question 2
Rebuild with regular expression
Question1
, The above
5
No need to implement
.
(2). Answer
Download the code and open the solution:
Validateemail. sln
Question 1:
Engineering
: Validateemail answers to
Http://www.rainsts.net/article.asp? Id = 485
In business design, data is often subject to definite format restrictions. We usually do this on the user input interface, but castle ar provides us with another alternative. This function is very useful when we cannot determine whether the class library or service caller will perform a format check. To implement this function, activerecordvalidationbase/activerecordvalidationbase
Verification features
Validatenotempty: The property cannot be empty
-regular expression )*/-(BOOL) isEmpty;/*! Check whether the email address is correct */-(BOOL) validateEmail;/*! Determine whether the verification code is correct */-(BOOL) validateAuthen;/*! Determine whether the password format is correct */-(BOOL) validatePassword;/*! Determine whether the mobile phone number is correct */-(BOOL) validatePhoneNumber;/*! Write regular expressions on your own for input judgment */-(BOOL) validateWithRegExp: (NSStri
-Mail is valid ";
}
}
}
?>
------ Solution --------------------
... What do I mean? Filter_input (): if the verification fails, false is returned.
If (filter_input (INPUT_GET, "email", FILTER_VALIDATE_EMAIL ))
{
Echo "E-Mail is not valid ";
}
If the variable is valid, the returned result is not valid.
Discussion
Reference:
You just reversed the logic.
Nun? Please advise. I feel more and more logic and often get confused.
------ Solution ----------
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.